package com.knowledge.util;

import java.io.UnsupportedEncodingException;

public class URLCodingUtil {
	
	public static final String UTF = "UTF-8";
	public static final String LATIN = "ISO-8859-1";
	
	public static final String encode(String str) {
		if (str == null) {
			return null;
		}
		String encodeing = str;
		
		try {
			str = new String(str.getBytes(UTF), LATIN);
		} catch (UnsupportedEncodingException e) {
			// do nothing
			// e.printStackTrace();
		}
		
		return str;
	}
	
	public static final String decode(String str) {
		if (str == null) {
			return null;
		}
		String decodeing = str;
		
		try {
			str = new String(str.getBytes(LATIN), UTF);
		} catch (UnsupportedEncodingException e) {
			// do nothing
			// e.printStackTrace();
		}
		
		return str;
	}

}
